package com.hanamaki.WebDriverTest.testng_selenium;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

public class FirefoxDriverTestNg {

    //注册驱动
    WebDriver driver;

    @BeforeMethod
    public void setUp() {
        //注册本地火狐打开的位置
        System.setProperty("webdriver.gecko.driver", "C:\\Program Files\\Mozilla Firefox\\geckodriver.exe");

        //初始化
        driver = new FirefoxDriver();

    }


    @Test
    public void test() {
        driver.get("https://www.baidu.com");

        // 点击看奥运
        WebElement element = driver.findElement(By.xpath("//*[@id=\"lm-new\"]/a"));
        element.click();
    }

    @AfterClass
    public void close() {
        driver.quit();
    }
}
